import requests

def sixteenToChinese(sixteen):
    hex_str = '%E7%9B%B4%E5%B1%9E%E6%9C%BA%E5%85%B3'
    chinese = bytes.fromhex(hex_str.replace('%', '')).decode('utf-8')
    return chinese



url = ''

headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36',
    'Content-Type' : 'application/x-www-form-urlencoded;charset=UTF-8',
    'Origin':'',
    'Referer':'',
    'Accept':'application/json, text/javascript, */*; q=0.01',
    'Host':'',
    'X-Requested-With':'XMLHttpRequest'
}

datastr='''csrf=7bac6c9fdcb843899b3eb01a92f9e418&organ_level=2&parent_type=region&type=0&tyshxydm=1152000000909013XD&code=1152000000909013XD&short_code=SZJGW&name=SZJGW&short_name=SZJGW&organ_type=9FB587BCDAA74286B7AD60567B26F79A&region_code=530000&region_name=%E4%BA%91%E5%8D%97%E7%9C%81&parent_code=240822041212&path_parent_code=&parent_name=%E7%9B%B4%E5%B1%9E%E6%9C%BA%E5%85%B3&sort_order=1&leader=SZJGW&phone=SZJGW&email=&zip_code=&is_law=0&is_hall=0&is_monitor=0&is_risk=0&is_center=0&win_num=0&address=111&page_home=11&industry=1&industry_name=%E6%94%BF%E5%BA%9C&gmorg_code=&remark='''

key_values = datastr.split('&')

data = {}
for key_value in key_values:
    arr = key_value.split('=')
    data[arr[0]]=arr[1]
   ## data.setdefault(__key=arr[0], __default=arr[1])

data['organ_type'] = sixteenToChinese(data['organ_type'])
data['parent_name'] = sixteenToChinese(data['parent_name'])
data['region_name'] = sixteenToChinese(data['region_name'])
data['industry_name'] = sixteenToChinese(data['industry_name'])
print(f'【data】:{data}')

cooks ='''JSESSIONID=71e2ffef-953c-410d-9e1f-8d95ea061c52; _c_WBKFRo=dYLgPDabUtVYdtc42t2T38vGKA8naMCLVxzaJNW6; webfinal.session.errorCount=0; James_cookie_sYQDUGqqzHtheme=custom'''
cookies={}
key_values = cooks.split(';')
for key_value in key_values:
    arr = key_value.split('=')
    cookies[arr[0]]=arr[1]

#
# print(data)
data['region_name']='云南省'
# print(cookies)
response=requests.post(url=url,data=data,headers=headers,cookies=cookies)


print(response.text)



# 删除语句
# delete   from   pub_organ
# where code ='1152000000909013XD';
#
#
#
#
# delete  from   pub_organ_map
# where org_code='1152000000909013XD';
#
# delete   from    pub_organ_of_view
# where org_code ='1152000000909013XD';
#
#
# delete   from  pub_organ_tree
# where org_code='1152000000909013XD';



